//
//  UseSpacer.swift
//  learn-ios
//
//  Created by Dong on 2022/4/5.
//

import SwiftUI

struct UseSpacer: View {
    var body: some View {
        VStack {
            
            // 使用垫片构建复杂布局
            
            HStack {
                Rectangle()
                    .foregroundColor(.yellow)
                    .frame(width: 100, height: 100, alignment: .center)
                Spacer()
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
                    .foregroundColor(.red)
            }
            
            HStack{
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
                    .foregroundColor(.blue)
            }
            
            Spacer()
            
            HStack{
                
                Spacer()
                
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
                    .foregroundColor(.gray)
                
                Spacer()
                
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
                    .foregroundColor(.pink)
                
                Spacer()
            }
            
            Spacer()
            
            HStack{
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
            }
            
            HStack {
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
                Spacer()
                Rectangle()
                    .frame(width: 100, height: 100, alignment: .center)
            }
            
            
        }
    }
}

struct UseSpacer_Previews: PreviewProvider {
    static var previews: some View {
        UseSpacer()
    }
}
